<?php

error_reporting(E_ALL);


set_magic_quotes_runtime(false);

if (get_magic_quotes_gpc()) {
	$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
	while (list($key, $val) = each($process)) {
		foreach ($val as $k => $v) {
			unset($process[$key][$k]);
			if (is_array($v)) {
				$process[$key][stripslashes($k)] = $v;
				$process[] = &$process[$key][stripslashes($k)];
			} else {
				$process[$key][stripslashes($k)] = stripslashes($v);
			}
		}
	}
	unset($process);
}

defined("RP") or define("RP", dirname(__FILE__) . DIRECTORY_SEPARATOR);

function __autoload($className) {

	if (strpos($className, 'Base') === 0) $className = "Models_generated_" . $className;

	$className = preg_replace("~_~", DIRECTORY_SEPARATOR, $className);
	$className = RP . "inc" . DIRECTORY_SEPARATOR . $className . ".php";
	
	if (file_exists($className)) require_once $className;

	return true;
}

set_exception_handler(array(new Error(), "exception"));
set_error_handler(array(new Error(), "error"));

date_default_timezone_set("Europe/Moscow");

spl_autoload_register("__autoload");
spl_autoload_register("Doctrine_Core::autoload");
spl_autoload_register(array("Doctrine_Core", 'modelsAutoload'));